package com.itheima;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class Demo4 {
    public static void main(String[] args) {
        HashMap<Student4, String> hm = new HashMap<>();

        Student4 s1 = new Student4("小红", 20);
        Student4 s2 = new Student4("小黄", 22);
        Student4 s3 = new Student4("小白", 25);
        Student4 s4 = new Student4("小蓝", 23);
        Student4 s5 = new Student4("小绿", 21);

        hm.put(s1, "北京海淀");
        hm.put(s2, "北京朝阳");
        hm.put(s3, "北京海淀");
        hm.put(s4, "北京顺义");
        hm.put(s5, "北京昌平");

        Set<Student4> stu = hm.keySet();
        for (Student4 key : stu) {
            String value = hm.get(key);
            System.out.println(key + "----" + value);
        }
        System.out.println("------------------");

        Set<Map.Entry<Student4, String>> entries = hm.entrySet();
        for (Map.Entry<Student4, String> entry : entries) {
            Student4 key = entry.getKey();
            String value = entry.getValue();
            System.out.println(key + "-----" + value);
        }
    }
}
